﻿var rootMenu = ["学员管理", "班级管理", "考试管理", "统计分析", "个人信息", "师生互动"];
var rootMenuLink = ["#", "#", "#", "#", "#", "#"];

var subMenu = [
                ["学员信息", "新增学员", "批量新增学员"]
                , ["开设班级", "班级信息"]
                , ["题库管理", "试卷管理", "学员成绩查询", "学员成绩输入"]
                , ["学员进度查询", "课程满意度分析", "认证整体满意度"]
                , ["修改密码", "个人信息"]
                , ["答疑"]
              ];
var subMenuLink = [
                    ["/student/List.aspx", "/student/Edit.aspx?act=n", "/student/EditPlural.aspx"]
                    , ["/classes/Edit.aspx?act=n", "/classes/ClassList.aspx"]
                    , ["/exam/QuestionList.aspx", "/exam/ExamList.aspx", "/exam/ScoreInquiry.aspx", "/exam/ScoreInput.aspx"]
                    , ["/statistics/Progress.aspx", "/statistics/CourseAnalysis.aspx", "/statistics/CertificateAnalysis.aspx"]
                    , ["/info/UpdatePwd.aspx", "/info/UpdateInfo.aspx"]
                    , ["/interactive/List.aspx"]
                  ];

function ShowSub(id) {
  var sub = document.getElementById("sub_" + id);
  var img = document.getElementById("m_img_" + id);

  if (sub.style.display != "none") {
    sub.style.display = "none";
    img.src = "/images/icon/arrow_right.gif";
  } else {
    for (var i = 0; i < rootMenu.length; i++) {
      if (i != id) {
        document.getElementById("sub_" + i).style.display = "none";
        document.getElementById("m_img_" + i).src = "/images/icon/arrow_right.gif";
      } else {
        document.getElementById("sub_" + i).style.display = "";
        document.getElementById("m_img_" + i).src = "/images/icon/arrow_down.gif";
      }
    }
  }
  SetLinkDefaultColor();
}

function GetMenu() {
  var html = "";
  html += "<div id=\"menu\">\r\n";
  html += "  <ul>\r\n";  
  html += GetMenuContent();  
  html += "  </ul>\r\n";
  html += "</div>\r\n";  
  return html;
}

function GetMenuContent() { 
  var html = "";

  for (var i = 0; i < rootMenu.length; i++) {
    html += "<li id=\"m_" + i + "\">\r\n";
    html += "  <div class=\"root\">\r\n";
    html += "    <div class=\"m_r\">\r\n";
    html += "      <div><a href=\"" + rootMenuLink[i] + "\" onclick=\"ShowSub(" + i + ");\">" + rootMenu[i] + "</a></div>\r\n";
    html += "      <img id=\"m_img_" + i + "\" alt=\"\" src=\"/images/icon/arrow_right.gif\" class=\"cursor\" onclick=\"ShowSub(" + i + ");\" />\r\n";
    html += "    </div>\r\n";
    html += "  </div>\r\n";
    html += "  <div id=\"sub_" + i + "\" class=\"sub\" style=\"display:none;\">\r\n";
    html += "    <ul>\r\n";

    for (var j = 0; j < subMenuLink[i].length; j++) {
      html += "      <li id=\"sub_" + i + "_" + j + "\"><a href=\"" + subMenuLink[i][j] + "\" target=\"managerFrame\" id=\"subHref_" + i + "_" + j + "\" onclick=\"SetCurrentLinkColor(" + i + "," + j + ");\">" + subMenu[i][j] + "</a></li>\r\n";
    }
    
    html += "    </ul>\r\n";
    html += "  </div>\r\n";
    html += "</li>\r\n";
  }
  
  return html;
}

function SetCurrentLinkColor(i, j) {
  SetLinkDefaultColor();
  document.getElementById("subHref_" + i + "_" + j).style.color = "#26ced7";
}

function SetLinkDefaultColor() {
  for (var i = 0; i < rootMenu.length; i++) {
    for (var j = 0; j < subMenu[i].length; j++) {
      document.getElementById("subHref_" + i + "_" + j).style.color = "#dddddd";
    }
  }
}